// To parse this JSON data, do
//
//     final notificationDetailModel = notificationDetailModelFromJson(jsonString);

import 'dart:convert';

import 'package:live_music/models/moment_detail_model.dart';

NotificationDetailModel notificationDetailModelFromJson(String str) =>
    NotificationDetailModel.fromJson(json.decode(str));

String notificationDetailModelToJson(NotificationDetailModel data) =>
    json.encode(data.toJson());

class NotificationListModel {
  List<NotificationDetailModel> list;
  NotificationListModel(this.list);

  factory NotificationListModel.fromJson(List<dynamic> list) {
    // 调用自身构造方法传值并返回
    return NotificationListModel(
      list
          .map((listItem) => NotificationDetailModel.fromJson(listItem))
          .toList(),
    );
  }
}

class NotificationDetailModel {
  NotificationDetailModel({
    this.id,
    this.category,
    this.type,
    this.receiveUserId,
    this.sendUserId,
    this.momentId,
    this.parentCommentId,
    this.commentId,
    this.artistId,
    this.createTime,
    this.updateTime,
    this.commentContent,
    this.parentCommentContent,
    this.sendUserName,
    this.sendUserAvatarUrl,
    this.moment,
  });

  int id;
  String category;
  String type;
  int receiveUserId;
  int sendUserId;
  int momentId;
  int parentCommentId;
  int commentId;
  int artistId;
  DateTime createTime;
  DateTime updateTime;
  dynamic commentContent;
  dynamic parentCommentContent;
  dynamic sendUserName;
  dynamic sendUserAvatarUrl;
  MomentDetailModel moment;

  factory NotificationDetailModel.fromJson(Map<String, dynamic> json) =>
      NotificationDetailModel(
        id: json["id"] == null ? null : json["id"],
        category: json["category"] == null ? null : json["category"],
        type: json["type"] == null ? null : json["type"],
        receiveUserId:
            json["receiveUserId"] == null ? null : json["receiveUserId"],
        sendUserId: json["sendUserId"] == null ? null : json["sendUserId"],
        momentId: json["momentId"] == null ? null : json["momentId"],
        parentCommentId:
            json["parentCommentId"] == null ? null : json["parentCommentId"],
        commentId: json["commentId"] == null ? null : json["commentId"],
        artistId: json["artistId"] == null ? null : json["artistId"],
        createTime: json["createTime"] == null
            ? null
            : DateTime.parse(json["createTime"]),
        updateTime: json["updateTime"] == null
            ? null
            : DateTime.parse(json["updateTime"]),
        commentContent: json["commentContent"] == null ? null :json["commentContent"],
        parentCommentContent:json["parentCommentContent"] == null ? null : json["parentCommentContent"],
        sendUserName:json["sendUserName"] == null ? null : json["sendUserName"],
        sendUserAvatarUrl: json["sendUserAvatarUrl"] == null ? null :json["sendUserAvatarUrl"],
        moment: json["moment"] == null
            ? null
            : MomentDetailModel.fromJson(json["moment"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id == null ? null : id,
        "category": category == null ? null : category,
        "type": type == null ? null : type,
        "receiveUserId": receiveUserId == null ? null : receiveUserId,
        "sendUserId": sendUserId == null ? null : sendUserId,
        "momentId": momentId == null ? null : momentId,
        "parentCommentId": parentCommentId == null ? null : parentCommentId,
        "commentId": commentId == null ? null : commentId,
        "artistId": artistId == null ? null : artistId,
        "createTime": createTime == null ? null : createTime.toIso8601String(),
        "updateTime": updateTime == null ? null : updateTime.toIso8601String(),
        "commentContent": commentContent,
        "parentCommentContent": parentCommentContent,
        "sendUserName": sendUserName,
        "sendUserAvatarUrl": sendUserAvatarUrl,
        "moment": moment == null ? null : moment.toJson(),
      };
}
